﻿/* BDVB-App
Copyright (C) 2014 Sascha Manns <Sascha.Manns@outlook.de>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


using System;
using System.Windows.Input;

using AppStudio.Services;

namespace AppStudio
{
    public class ActionCommands
    {
        static public ICommand ShowImage
        {
            get
            {
                return new RelayCommandEx<string>((param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        NavigationServices.NavigateToPage("ImageViewer", param);
                    }
                });
            }
        }

        static public ICommand MailTo
        {
            get
            {
                return new RelayCommandEx<string>((param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        string url = String.Format("mailto:{0}", param);
                        NavigationServices.NavigateTo(new Uri(url));
                    }
                });
            }
        }

        static public ICommand CallToPhone
        {
            get
            {
                return new RelayCommandEx<string>((param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        string url = String.Format("tel:{0}", param);
                        NavigationServices.NavigateTo(new Uri(url));
                    }
                });
            }
        }

        static public ICommand MusicPlayArtistMix
        {
            get
            {
                return new RelayCommandEx<string>(async (param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        await NokiaMusicServices.PlayArtistMix(param);
                    }
                });
            }
        }

        static public ICommand MusicLaunchSearch
        {
            get
            {
                return new RelayCommandEx<string>(async (param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        await NokiaMusicServices.LaunchSearch(param);
                    }
                });
            }
        }

        static public ICommand MusicLaunchArtist
        {
            get
            {
                return new RelayCommandEx<string>(async (param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        await NokiaMusicServices.LaunchArtist(param);
                    }
                });
            }
        }
        static public ICommand MapsPosition
        {
            get
            {
                return new RelayCommandEx<string>(async (param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        await NokiaMapsServices.MapPosition(param);
                    }
                });
            }
        }

        static public ICommand MapsHowToGet
        {
            get
            {
                return new RelayCommandEx<string>(async (param) =>
                {
                    if (!String.IsNullOrEmpty(param))
                    {
                        await NokiaMapsServices.HowToGet(param);
                    }
                });
            }
        }

        private static void NavigateTo(string protocol, string param)
        {
            if (!String.IsNullOrEmpty(param))
            {
                string url = String.Format("{0}:{1}", protocol, param);
                var uri = new Uri(url);
                NavigationServices.NavigateTo(uri);
            }
        }
    }
}
